package xyz.syyrjx.blog.entity.ai.chat;

import com.fasterxml.jackson.core.JsonProcessingException;
import xyz.syyrjx.blog.util.ConstValuePool;

import java.util.List;

/**
 * @author 大地崩坏苍蝇兽
 * @date 2024/2/18 16:15
 * @description ...
 * @since v0.0.1
 */
public class ChatResponse {

    private String id;

    private String object;
    private Long created;
    private String model;
    private String system_fingerprint;
    // GPT返回的对话列表
    private List<Choice> choices;

    public ChatResponse() {
    }

    public ChatResponse(String id, String object, Long created, String model, String system_fingerprint, List<Choice> choices) {
        this.id = id;
        this.object = object;
        this.created = created;
        this.model = model;
        this.system_fingerprint = system_fingerprint;
        this.choices = choices;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getObject() {
        return object;
    }

    public void setObject(String object) {
        this.object = object;
    }

    public Long getCreated() {
        return created;
    }

    public void setCreated(Long created) {
        this.created = created;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getSystem_fingerprint() {
        return system_fingerprint;
    }

    public void setSystem_fingerprint(String system_fingerprint) {
        this.system_fingerprint = system_fingerprint;
    }

    public List<Choice> getChoices() {
        return choices;
    }

    public void setChoices(List<Choice> choices) {
        this.choices = choices;
    }

    public static class Choice {

        private int index;
        private Delta delta;

        private Object logprobs;
        private Object finish_reason;

        public Choice() {
        }

        public Choice(int index, Delta delta, Object logprobs, Object finish_reason) {
            this.index = index;
            this.delta = delta;
            this.logprobs = logprobs;
            this.finish_reason = finish_reason;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public Delta getDelta() {
            return delta;
        }

        public void setDelta(Delta delta) {
            this.delta = delta;
        }

        public Object getLogprobs() {
            return logprobs;
        }

        public void setLogprobs(Object logprobs) {
            this.logprobs = logprobs;
        }

        public Object getFinish_reason() {
            return finish_reason;
        }

        public void setFinish_reason(Object finish_reason) {
            this.finish_reason = finish_reason;
        }
    }

    @Override
    public String toString() {
        try {
            return ConstValuePool.OBJECT_MAPPER.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }
}
